<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>


<script type="text/javascript">

//秒杀活动分页
$(function() {
	$("#pager").pager({pagenumber: ${page}, 
		pagecount: ${totalPage},
		buttonClickCallback: function(page){
			$("#content_detail").load("seckillList.cms?page="+page+"&seckillType="+$("#content_type_query").val());
		}
	});
	$("#content_type_query").val("${seckillType}");//初始化类别下拉框
});
	
	
//增加活动
	function addSeckill() {
	
		$("#addSeckillDiv").show();
		$("#upadteSeckillDiv").hide();
		$("#addSeckillDiv").load("getNewSeckill.cms");
	}
	//关闭添加活动
	function closedReleaseSeckill() {
		$("#addSeckillDiv").hide();
	}
	//关闭更新
	function closedUpadteSeckill(){
		$("#upadteSeckillDiv").hide();
	}
	//删除时间段
    function moveseckillTime(obj){
    	$(obj).parent().remove();
    }
	//删除活动
	function deleteSeckill(seckillId){
		if(confirm("你确定删此活动内容？")){
			$.post("deleteSeckill.cms",{
				seckillId:seckillId
			},function(data){
				if(data=='success'){
					$("#content_detail").load("seckillList.cms");
				}
			})
		}
	}
	//更新活动
	function updateSeckill(seckillId){
		//alert(seckillId);
			$("#upadteSeckillDiv").load("updateSeckill.cms?seckillId="+seckillId);
			$("#upadteSeckillDiv").show();
			$("#addSeckillDiv").hide();
	}
	//结束活动
	function closedSeckill(seckillId){
		
		if(confirm("你确定结束活动？")){
			$.post("closedSeckill.cms",{
				seckillId:seckillId
			},function(data){
				if(data=='success'){
					$("#content_detail").load("seckillList.cms");
				}
			})
		}
	}
	//查询用户
	function selectSeckillUser(seckillId){
		$("#selectSeckillUser").show();
		$("#selectSeckillUser").load("selectSeckillUser.cms?seckillId="+seckillId);
	}
	//关闭用户列表
	function closeSeckillUser(){
		$("#selectSeckillUser").hide();
	}
	//试试手气列表
	function selectBySeckillType(){
		var seckillType=$("#content_type_query").val();
		$("#content_detail").load("seckillList.cms?seckillType="+seckillType);
	}
</script>
选择分类：<select id="content_type_query" onchange="selectBySeckillType();">
                <option value="01">精彩活动</option>
                 <option value="02">试手气</option>
        </select>
---------------------------------------------------------------------------------------------------------------
<input type="button" value="添加新活动"
	style="width: 80px; height: 25px; color: blue;" onclick="addSeckill();">

<br />

<div id="seckillList" style="margin-top: 20px">
	<strong style="font-size: 15px; color: red">秒杀活动列表：</strong>
	<table border="1">
		<tr>
			<td>秒杀编号</td>
			<td>秒杀标题</td>
			<td style="width: 200px">秒杀活动内容</td>
			<td>按键名称</td>
			<td>秒杀图片</td>
			<td>日常活动时间段</td>
			<td>秒杀数据列表</td>
			<td>状态</td>
			
			<td style="color: red">操作</td>
		</tr>
		<c:forEach items="${seckillList}" var="seckill">
			<tr>
				<td><c:out value="${seckill.identifier}" /></td>
				<td><c:out value="${seckill.title}" /></td>
				<td style="width: 200px">${seckill.body}</td>
				<td><c:out value="${seckill.buttonName}" /></td>
				<td><img src="${seckill.picUrl}" alt="图片" style="width: 50px;height: 50px"></td>
				<td>
				<c:if test="${seckill.isDaily}">
				<div>开始时间：${seckill.startDate}</div>
				<div>开始时间：${seckill.endDate}</div>
				</c:if>
				</td>
				<td><c:forEach items="${seckill.seckillTimeList}" var="seckillTime">
				<div style="color: red;">-------------------</div>
				<div>开始时间：${seckillTime.startTime}</div>
				<div>结束时间：${seckillTime.endTime}</div>
				<div>剩余数量：${seckillTime.count}</div>
				<div>默认秒杀数量：${seckillTime.customCount}</div>
				</c:forEach>
				</td>
				<td>
				<c:if test="${seckill.enabled=='false'}">已结束</c:if>
				<c:if test="${seckill.enabled=='true'}">进行中..</c:if>
				</td>
				<td><div><a href="javascript:void(0);"
					onclick="deleteSeckill('${seckill.identifier}')">删除</a></div>
					<div><a href="javascript:void(0);"
					onclick="updateSeckill('${seckill.identifier}')">修改</a></div>
					<div><a href="javascript:void(0);"
					onclick="closedSeckill('${seckill.identifier}')">结束</a></div>
					<div><a href="javascript:void(0);"
					onclick="selectSeckillUser('${seckill.identifier}')">参与用户</a></div>
				</td>
			</tr>
		</c:forEach>
	</table>
	<div id="pager" class="h_page">分页</div>
</div>
<br />
<div id="selectSeckillUser" style="display: none; margin-top: 15px;">
</div>
<div id="addSeckillDiv" style="display: none; margin-top: 15px;">
</div>
<div id="upadteSeckillDiv" style="display: none; margin-top: 15px;"></div>
<br />
<br />
<br />